// pages/self/self.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
    teams: [],
    hasMore: true,
    showLoading: true,
    start: 0,
    hidden: false,
    hasRefesh: false,
    tabBar: {
      "color": "#878787",
      "selectedColor": "#000",
      "borderStyle": "black",
      "backgroundColor": "#fcfcfc",
      "list": [
        {
          "pagePath": "../team_index/index",
          "iconPath": "../../static/imgs/tabBar/index.png",
          "selectedIconPath": "../../static/imgs/tabBar/index-on.png",
          "text": "首页"
        },
        {
          "pagePath": "../team_post/post",
          "iconPath": "../../static/imgs/tabBar/add.png",
          "selectedIconPath": "../../static/imgs/tabBar/add-on.png",
          "text": "发布"
        },
        {
          "pagePath": "../team_self/self",
          "iconPath": "../../static/imgs/tabBar/account.png",
          "selectedIconPath": "../../static/imgs/tabBar/account-on.png",
          "text": "我的",
          active: true
        }
      ],
      "position": "bottom"
    }
  },
  //事件处理函数
  bindViewTap2: function (e) {
    var ds = e.currentTarget.dataset;
    wx.navigateTo({
      url: '../team_self/mydetail/mydetail?title=' + ds.title + '&id=' + ds.id + '&st=' + ds.starttime + '&et=' + ds.endtime + '&c=' + ds.content + '&rc=' + ds.rcontent + '&cw=' + ds.cw + '&cv=' + ds.cv + '&_id=' + ds._id,
    })
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onShow: function (options) {
    var that = this;
    //var userid = wx.getStorageSync('userid')
    var id = "";
    var auth = getApp().globalData.kind;
    if (auth == "1") {
      id = getApp().globalData.user.studentNo
    } else if (auth == "2") {
      id = getApp().globalData.user.teacherNo
    } else if (auth == "3") {
      id = getApp().globalData.user.adminNo
    } else if (auth == "4") {
      id = getApp().globalData.user.donatorNo
    };
    wx.request({
      url: getApp().globalData.my_server +'/team/my',
      method: 'POST',
      header: {
        "Content-Type": "application/x-www-form-urlencoded"
      },
      data: {
        id: id,
        role: getApp().globalData.kind
      },
      success: function (res) {
        console.log(res);
        that.setData({
          teams: res.data,
          hidden: true,
          hasRefesh: false,
        });
      },
    })
  },
  //加载更多
  loadMore: function (e) {
    var that = this;
    that.setData({
      hasRefesh: true,
    });
    if (!this.data.hasMore) return
    this.onLoad()
    setTimeout(() => {
      wx.stopPullDownRefresh()//表示停止刷新
    }, 1000)
  },
  //刷新处理
  refesh: function (e) {
    var that = this;
    that.setData({
      hasRefesh: true,
    });
    this.onLoad()
    setTimeout(() => {
      wx.stopPullDownRefresh()//表示停止刷新
    }, 1000)
  }
})